package com.ruoyi.project.report.order.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.report.order.domain.OrderReport;
import com.ruoyi.project.report.order.mapper.OrderReportMapper;
import com.ruoyi.project.report.order.service.IOrderReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class OrderReportServiceImpl implements IOrderReportService {

    @Autowired
    private OrderReportMapper orderReportMapper;

    @Override
    public List<OrderReport> selectOrderReportByDate(String startDateStr, String endDateStr) {
        String startStr;
        String endStr;
        if (startDateStr == null || startDateStr.equals("")) {
            startStr = DateUtils.getMonthFirstDay();
        } else {
            startStr = startDateStr;
        }
        if (endDateStr == null || endDateStr.equals("")) {
            endStr = DateUtils.getMonthLastDay();
        } else {
            endStr = endDateStr;
        }
        Long days = DateUtils.getDateGapDays(DateUtils.parseDate(endStr), DateUtils.parseDate(startStr));

        return orderReportMapper.selectOrderReportInfo(startStr, endStr, days);
    }
}
